home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / inceval.zip / 32BIT / INCREG.PAS < prev   
Pascal/Delphi Source File  |  1996-06-11  |  5KB  |  142 lines

  1. unit IncReg;
  2. {******************************************************************************}
  3. {                                                                              }
  4. {                           IMPORTANT NOTICE                                   }
  5. {                                                                              }
  6. {          (c) Copyright 1996 by Softouch Development Incorporated             }
  7. {                                                                              }
  8. {                         ALL RIGHTS RESERVED                                  }
  9. {                                                                              }
  10. {       Software and documentation are the confidential property and           }
  11. {       contain trade secrets of Softouch Development Incorporated.            }
  12. {       Any copying, use, disclosure, modification, or transfer by rental,     }
  13. {       sale, or otherwise without the written consent of Softouch             }
  14. {       Development Incorporated is strictly prohibited.                       }
  15. {                                                                              }
  16. {       Portions may be Copyright (c) 1995 Borland International.              }
  17. {       All restriction apply.                                                 }
  18. {******************************************************************************}
  19. {  IncBase    - Main base class of all Incremental Combos.                     }
  20. {  IncCombo   - Your basic incremental combo with a list box of items.         }
  21. {  IncDBCombo - Your basic DataAware incremental combo with list box of items. }
  22. {  IncDBSrc   - Incremental Combo that is used to navigate a DataSet.          }
  23. {  IncDBLup   - DataAware Incremental Lookup Combo.                            }
  24. {******************************************************************************}
  25. {                                                                              }
  26. {  Problem Log                                                                 }
  27. {  03/14/96  Started problem log                                               }
  28. {                                                                              }
  29. {******************************************************************************}
  30. interface
  31.  
  32. uses
  33.     {$IFDEF Win32}
  34.     Windows,
  35.     {$ELSE}
  36.     Forms,
  37.     {$ENDIF}
  38.     Classes, DsgnIntf, Dialogs, Controls, IncAbout, IncBase, IncCombo, IncDBCmb, IncDBSrc, IncDBLup,
  39.     DBTables;
  40.  
  41. type
  42.     TIncComboAboutBox = class(TComponentEditor)
  43.     procedure ExecuteVerb(Index: Integer); override;
  44.     function GetVerb(Index: Integer): string; override;
  45.     function GetVerbCount: Integer; override;
  46.     end;
  47.  
  48.   TDBStringProperty = class(TStringProperty)
  49.   public
  50.      function GetAttributes: TPropertyAttributes; override;
  51.      procedure GetValueList(List: TStrings); virtual; abstract;
  52.      procedure GetValues(Proc: TGetStrProc); override;
  53.   end;
  54.  
  55.   TLookupIndexProperty = class(TDBStringProperty)
  56.   public
  57.      procedure GetValueList(List: TStrings); override;
  58.   end;
  59.  
  60.   TSearchIndexProperty = class(TDBStringProperty)
  61.   public
  62.      procedure GetValueList(List: TStrings); override;
  63.   end;
  64.  
  65. procedure Register;
  66.  
  67. implementation
  68.  
  69. procedure TIncComboAboutBox.ExecuteVerb(Index: Integer);
  70. var IncAboutBox: TIncAboutBox;
  71. begin
  72.     IncAboutBox := TIncAboutBox.Create(Application);
  73.     IncAboutBox.ShowModal;
  74.     IncAboutBox.Destroy;
  75. end;
  76.  
  77. function TIncComboAboutBox.GetVerb(Index: Integer): string;
  78. begin
  79.   Result := 'About...';
  80. end;
  81.  
  82. function TIncComboAboutBox.GetVerbCount: Integer;
  83. begin
  84.   Result := 1;
  85. end;
  86.  
  87. function TDBStringProperty.GetAttributes: TPropertyAttributes;
  88. begin
  89.     Result := [paValueList, paSortList, paMultiSelect];
  90. end;
  91.  
  92. procedure TDBStringProperty.GetValues(Proc: TGetStrProc);
  93. var
  94. I: Integer;
  95. Values: TStringList;
  96. begin
  97.     Values := TStringList.Create;
  98.     try
  99.         GetValueList(Values);
  100.         for I := 0 to Values.Count - 1 do Proc(Values[I]);
  101.     finally
  102.         Values.Free;
  103.     end;
  104. end;
  105.  
  106. procedure TLookupIndexProperty.GetValueList(List: TStrings);
  107. begin
  108.     with (GetComponent(0) as TDBIncLookupCombo) do
  109.         begin
  110.         if (LookupSource <> Nil) and (LookupSource.DataSet <> Nil)
  111.         and LookupSource.DataSet.InheritsFrom(TTable) then
  112.             TTable(LookupSource.DataSet).GetIndexNames(List);
  113.         end;
  114. end;
  115.  
  116. procedure TSearchIndexProperty.GetValueList(List: TStrings);
  117. begin
  118.     with (GetComponent(0) as TDBIncSearchCombo) do
  119.         begin
  120.         if (LookupSource <> Nil) and (LookupSource.DataSet <> Nil)
  121.         and LookupSource.DataSet.InheritsFrom(TTable) then
  122.             TTable(LookupSource.DataSet).GetIndexNames(List);
  123.         end;
  124. end;
  125.  
  126. procedure Register;
  127. begin
  128.   RegisterComponentEditor(TIncCombo        ,TIncComboAboutBox);
  129.   RegisterComponentEditor(TDBIncCombo      ,TIncComboAboutBox);
  130.   RegisterComponentEditor(TDBIncLookupCombo,TIncComboAboutBox);
  131.   RegisterComponentEditor(TDBIncSearchCombo,TIncComboAboutBox);
  132.   RegisterComponents('IncCombos',[TIncCombo]);
  133.   RegisterComponents('IncCombos',[TDBIncCombo]);
  134.   RegisterComponents('IncCombos',[TDBIncLookupCombo]);
  135.   RegisterComponents('IncCombos',[TDBIncSearchCombo]);
  136.   RegisterPropertyEditor(TypeInfo(string),TDBIncSearchCombo,'LookupIndex',TSearchIndexProperty);
  137.   RegisterPropertyEditor(TypeInfo(string),TDBIncLookupCombo,'LookupIndex',TLookupIndexProperty);
  138. end;
  139.  
  140.  
  141. end.
  142.